home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
BASIC
/
0006.ZIP
/
COVER.DOC
< prev
next >
Wrap
Text File
|
1983-06-16
|
13KB
|
265 lines
SORTED DISKETTE DIRECTORY LISTING - IBM PC
Just what you always needed! Yet another redundant, dupli-
cative, and space occupying utility... Hopefully, this fills a
nitch left open in the array of PC-DOS utilities. This one sorts
and formats the directory data and prints it so its "just right"
to fit inside the diskette envelope. You have to provide your
own paper cutter... the utility does the rest.
The program runs under PC-DOS Versions 1.x or 2.0, and will
operate on any normal configuration. It does expect the IBM or
Epson MX80 printer (or equivalent), but should be easily modified
to apply to any printer that offers "condensed" print and 8 lines
per inch line spacing. It is written in Assembler, but uses no
macros, so either ASM or MASM can be used to assemble the source
code. LINK and EXE2BIN are required.
It has two known limitations. It ignores hidden files, and
if you're a Version 2.0 user and have implemented the "tree"
directory paths with mulitple directories on a diskette, the
subordinate directories will also be ignored. Since the "path"
logic seems primarily aimed at fixed disk, and this utility is
directed towards diskettes, these limitations should not effect
most users. Someday I'll get rich, and get a fixed disk, but
till then....
The utility resulted from a scenario in which I found myself
a frequent player. I hope I'm alone in the world, but I suspect
I'm not. The scenario goes like this... Phone rings. Voice on
the line says, "Say Dan, you know that program that puts a double
whammy on the singlefritz when you've juiced the slobert? My
only copy got clobbered, so would you check and see if you've got
a backup?" Well, I've got something in excess of 200 diskettes
neatly filed in boxes, labeled correctly, etc. The only problem
is that a label which says "Miscelaneous Junk Utilities" may have
meant something when I wrote it, but it sure doesn't mean much
now. Next step is to break in to what ever is currently running
on the PC, and start sticking in diskettes to do a DIR to check.
Actually this kind of event led to my writing a "Catalog"
facility (which does everything but cook) for the PC, but after
some months of use, I found that the part of this relatively
large and complex package that I really used, was this simple
print utility. So I "extracted" that portion of the big system
to pass on to the rest of the world. I'm placing this code in
"Public Domain", so use it as you will.
The program is called "COVER" and is composed of seven
separately assembled modules: COVER, COTITL, COFREE, COSCAN,
COSORT, COPRNT, and COENDP. The listings are commented, but I'll
include a few words on each of the modules.
COVER is the main control module, and contains the major
loop. Its first action is to preset the printer to 8 lines per
inch, condensed print, and a 44 line page. If you have a
1
Diskette Directory Listing
"different" printer, you may need to change the control stream
defined at SETPRT. The final zero in the control stream is not
sent to the printer, but marks the end of string for DOPRT.
Next, COVER checks for the DOS Version. The return from the
30H call (which is valid on release 1.x), is the release and
version numbers under V2.0 of DOS. On prior releases it returns
a zero. This code simply sets a switch that will be tested
later. The "default" drive is then determined and saved, and
finally, the number of drives on the configuration is determined.
COVER then prompts for the drive letter for the drive
containing the diskette to be listed. The single character input
is first checked for an "Escape" (all done, so get off), and then
the drive character is verified for a "legal" drive designator.
The prompt starts the main loop, which ends after all processing
is done for one diskette. COVER then calls GETTTL (Get Title),
GETFRE (Determine free space on diskette), SCAN (Load all
directory entries into an internal stack), SORT (Sequence the
stacked entries), and PRINT (which formats and prints the stacked
entries). Each of the called routines will be mentioned in the
following paragraphs.
When the Escape character is sensed, COVER forces a page
restore to complete the current listing, resets the "default"
drive to its value on entry, conditionally forces out one more
"page" to restore the paper to the true top of forms, and then
resets the printer to "power up" status. The control string for
the latter is at RESPRT so the "different" printer users may
modify that string if required.
GETTTL is a primitive module which solicits a "title" from
the user. Forty characters are allowed, and the standard DOS
function is used to get this string. Nul titles are permissable.
The DOS function is also used to get the system date. DECMAL is
a local subroutine that coverts the content of the AL to two
decimal digits in the AH and AL and then stores them in the area
defined by the DI register.
GETFRE computes the "free" space available on the diskette
and places the ASCII decimal result in the title line. This
program is the reason COVER checked for the DOS Version. V2.0
provides a "nice" function that will give the free space
directly, but does not allow you to gain addressability to the
File Allocation Table (FAT). V1.x did not have this feature, but
did provide addressability to the FAT. Since this program was to
be used in both environments, this code has two paths. The code
following the version test is for V2.0. Code starting at the
label VERS1 is that process necessary to determine free space
under the older versions of DOS. VCOM marks the point where the
two paths re-join. If you're only running V2.0, you can decrease
the size of the utility by removing the code from the instruction
"JMP VCOM" to the instruction before that labeled VCOM. Finally,
CONVRT is a public subroutine that converts the AX/DX content to
a max of a six digit number, leading zero surpressed, and places
2
Diskette Directory Listing
the result at the area pointed to by the DI register.
SCAN does the normal DOS function calls to "find" an all
"wild card" file name. This process repeats until the entire
directory has been scanned. The result is placed in a stack and
a pointer to the start of the entry is placed in a pointer list.
The format of the stack entries is the file-name.typ followed by
a zero byte, and then the four byte file size field from the
directory. Since the data transfer area (DTA) has not been reset
this module finds it input in the default DTA at 80H in the
program prefix.
SORT is a simple "bubble" sort of the stacked entries, but
is driven from the pointer list. Yes, I know a shell sort is
faster, but for a max of 112 entries, an old fashioned bubble
uses less memory!
PRINT simply uses the sorted pointers to form the final
output. The title line has already been formed by the prior
modules. The local subroutine PRTENT uses CONVRT to format the
file sizes. Four columns will "fit" within the print size
required, so PRINT initially computes column length. An inner
and an outer loop controls the print process. The inner loop
prints one entry each execution, and is executed four times per
line. The outer loop is cycled once per entry in a single
column.
The source module COENDP includes no code. This module
simply provides addressability to the memory above the program
code. V2.0 provides this function in a much "cleaner" manner,
but since this utility is to run on either Version, this
subterfuge is necessary.
That's a very quick "walk through" for the code, but
together with the source comments, it should provide sufficent
information for any extensions or modifications you may choose to
make. Key the source in, and assemble the seven modules. The
Link control stream is also included in the listings. Be very
sure that the module COENDP occurs last in the control stream, as
shown in the listing. Otherwise you'll be stacking directory
entries over some of the code.
For those of you who are not familiar with "COM" files, ALL
segment registers are preset by the operating system to the same
value, so although you see no code for setting the DS and ES
segment registers, they contain the same value as the CS and SS
at program initiation so change is not required. The stack is
automatically allocated at the "top" of the segment (64K) the
program is loaded to, so no stack establishment is required.
Finally, the established stack is initialized so that a "NEAR"
return at end of program will return you to DOS correctly, so
long as the CS register has not been changed. This program uses
the 20H termination call, but could do a simple near RET with the
same result.
3
Diskette Directory Listing
Link will provide console messages saying that there is no
stack segment (that's right), and that there is one error (that's
false). This response is normal when you're preparing a "COM"
file. If you get more errors or other indications, you'd better
re-check your work.
Now you're ready to run EXE2BIN, and then rename the
resultant file (COVER.BIN) to COVER.COM. That's all it takes.
The utility will prompt with a console message asking which drive
contains the diskette to be listed, so enter the single character
drive designator appropriate (A-G). No colon or carriage return
will be required. The program will then prompt for the title you
wish to appear on the top line of the list. A forty character
field is provided. If you do not want the title, simply hit the
"Enter" key, and the top line of the listing will be blank except
for the date. When the first listing is complete, the utility
will loop back and ask for another drive. This iterative process
will continue until you repond with an "Escape" key to the drive
request prompt. Exit is then made to the DOS.
Note that although the utility prints two envelope covers
per page, forms will be advanced to the "top of form" position in
effect when the utility was started. The printer will also be
restored to "power up" status. If you use Control-Break to exit
the utility, this will not be true, so you'll have to manually
re-aline and reset your printer.
There's not that much code in this utility, but as always,
if you don't want to "poke" this in yourself, send me a diskette,
with mailer and postage, and I'll copy my source and return it to
you, or if you prefer, send me a check for $7.50 and I'll send
you a new diskette (single surface - 8 sector). You can contact
me at the address or phone given below:
Dan Daetwyler
Route 5, Box 518A
Springdale, Arkansas 72764
501-756-0212
4